<template>
  <div>
    <div class="dcenter">
      <el-card class="box-card">
        <h2>住户</h2>
        <el-input
          style="margin-top: 20px"
          v-model="data.name"
          placeholder="请输入姓名"
        ></el-input>
        <el-input
          style="margin-top: 20px"
          v-model="data.card"
          placeholder="请输入身份证号"
        ></el-input>
        <el-button
          style="margin-top: 20px; width: 80px; height: 40px"
          @click="denglu"
          type="primary"
          >登录</el-button
        >
      </el-card>
    </div>
  </div>
</template>

<script>
export default {
  name: "login",
  data() {
    return {
      data: {
        name: "",
        card: "",
      },
    };
  },
  mounted() {},
  methods: {
    async denglu() {
      let result = await this.$API.myapi.reqLogin(this.data);
      console.log(result.data.code);
      if (result.data.code == 20000) {
        console.log("是的");
        let location = { name: "Guest", query: { id: this.data.card } };
        console.log(result.data.data);
        this.$router.push(location);
      } else {
        this.$notify({
          title: "警告",
          message: "无此入住客户",
          type: "warning",
        });
      }
    },
  },
};
</script>
<style  scoped>
.box-card {
  width: 280px;
  height: 240px;
}
* {
  margin: 0;
  padding: 0;
}
.dcenter {
  width: 200px;
  height: 200px;

  position: absolute;
  top: 50%;
  left: 50px;
  transform: translate(390%, -50%);
}
</style>
